package org.xtremeobjects.forms.ui;

import org.xtremeobjects.domain.model.Clazz;
import org.xtremeobjects.domain.model.ClazzFactoryImpl;
import org.xtremeobjects.domain.model.ClazzRepository;

import com.google.inject.Inject;

public class XObjectEditorInputFactory {

	private ClazzRepository repository;

	@Inject
	public XObjectEditorInputFactory(ClazzRepository repository) {
		this.repository = repository;
	}

	public XObjectEditorInput create(Object data) {
		Clazz clazz = repository.findOrCreateByClass(data.getClass());
		return new XObjectEditorInput(clazz.getName(), clazz.getId(data));

	}
}
